# -*- coding: utf-8 -*-
# @Author : HaleShi
# @Time : 2023-06-16
# @File : 2_hook.py


import frida
import sys

rdev = frida.get_remote_device()
session = rdev.attach("Momo")

scr = """
Java.perform(function () {
    var a = Java.use("com.immomo.momo.protocol.http.a.a");
    a.doPost.overload('java.lang.String', 'java.util.Map', '[Lcom.immomo.http.a;', 'java.util.Map', 'int').implementation = function(str, map, aVarArr, map2, i2){
        var result = "";
        var keyset = map.keySet();
        var it = keyset.iterator();
        while(it.hasNext()){
            var keystr = it.next().toString();
            var valuestr = map.get(keystr).toString();
            result += valuestr;
        }
        console.log("——————————————————————这是str",str);
        console.log("——————————————————————这是map",result);
        console.log("——————————————————————这是aVarArr",aVarArr);
        console.log("——————————————————————这是map2",map2);
        console.log("——————————————————————这是i2",i2);
        
        var res = this.doPost(str, map, aVarArr, map2, i2)
        
        console.log("——————————————————————这是返回值",res);
    };
});
"""

script = session.create_script(scr)


def on_message(message, data):
    print(message, data)


script.on("message", on_message)

script.load()
sys.stdin.read()
